#include "texteditdialog.h"
#include "ui_texteditdialog.h"
#include <QTextDocument>
#include <QTextFrame>
#include <QTextFrameFormat>

TextEditDialog::TextEditDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::TextEditDialog)
{
    ui->setupUi(this);
    QTextDocument * document = ui->textEdit->document();

    QTextFrame * rootFrame = document->rootFrame();
    QTextFrameFormat format;
    format.setBorderBrush(Qt::red);
    format.setBorder(3);
    rootFrame->setFrameFormat(format);
}

TextEditDialog::~TextEditDialog()
{
    delete ui;
}

void TextEditDialog::on_pushButton_clicked()
{
    QTextFrameFormat format;
    format.setBackground(Qt::lightGray);
    format.setMargin(10);
    format.setPadding(5);
    format.setBorder(2);
    format.setBorderStyle(QTextFrameFormat::BorderStyle_Dotted);
    QTextCursor cursor = ui->textEdit->textCursor();
    cursor.insertFrame(format);
}

void TextEditDialog::insertImage() {

}

